<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\Url;

$this->title = Yii::$app->name;

?>

<div class="site-index">
    <div class="body-content">

        <div class="row">
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h3><?=$new_order ?><sup style="font-size: 20px"> 笔</sup></h3>

                        <p>新订单 / 待发货</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-shopping-cart"></i>
                    </div>
                    <?=Html::a('点击查看 <i class="fa fa-arrow-circle-right"></i>', Url::to(['/store/order/index', 'OrderGoodsSearch' => ['status' => 1]]), ['class' => 'small-box-footer']) ?>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-yellow">
                    <div class="inner">
                        <h3><?=$express_order ?><sup style="font-size: 20px"> 笔</sup></h3>

                        <p>已发货 / 待结算</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-truck"></i>
                    </div>
                    <?=Html::a('点击查看 <i class="fa fa-arrow-circle-right"></i>', Url::to(['/store/order/index', 'OrderGoodsSearch' => ['status' => 2]]), ['class' => 'small-box-footer']) ?>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-green">
                    <div class="inner">
                        <h3><?=$total_order ?><sup style="font-size: 20px"> 元</sup></h3>

                        <p>本月销售额</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-bar-chart"></i>
                    </div>

                    <?=Html::a('点击查看 <i class="fa fa-arrow-circle-right"></i>', Url::to(['/store/order/index', 'OrderGoodsSearch' => ['is_pay' => 1]]), ['class' => 'small-box-footer']) ?>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-red">
                    <div class="inner">
                        <h3><?=$settlement_order; ?><sup style="font-size: 20px"> 元</sup></h3>

                        <p>可结算提现</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-rmb"></i>
                    </div>
                    <a href="#" class="small-box-footer">去提现 <i class="fa fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
        </div>

    </div>
    <div class="row">
        <div class="col-md-9">
            <div class="box box-info">
                <div class="box-header">
                    <div class="box-title">近10笔订单</div>
                </div>
                <div class="box-body">
                    <?=GridView::widget([
                        'dataProvider' => $orders,
                        'pager' => false,
                        'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
                        'headerRowOptions' => ['class'=>'x'],
                        'layout' => "{items}",
                        'columns' => [
                            'order.created_at:datetime',
                            [
                                'attribute' => 'logo',
                                'width'=>'50px',
                                'content' => function ($model) {
                                    return Html::img($model->logo, ['style' => 'max-width:30px;max-height:30px;']);
                                }
                            ],
                            'title',
                            'goods_sn',
                            'cost_price',
                            'num',
                            [
                                'header' => '状态',
                                'width'=>'120px',
                                'content'=>function ($model) {
                                    $status_option = $model->orderStore->status_option;
                                    $text = $status_option[$model->order->type][$model->orderStore->status];
                                    $classes = ['text-muted', 'text-aqua', 'text-yellow', 'text-green', 'text-muted'];
                                    return Html::tag('span', $text, ['class' => $classes[$model->orderStore->status]]);
                                }
                            ],
                            [
                                'width'=>'100px',
//                        'filter' => false,
                                'content'=>function ($model) {
                                    $html = '<i class="hidden">'.$model->order_id.'</i>';
                                    if ($model->orderStore->status == 1) {
//                                $html .= Html::a('发货', Url::to(['view', 'id' => $model->orderStore->id]), ['class' => 'btn btn-warning btn-sm']);
                                    }
                                    $html .= Html::a('<i class="fa fa-files-o"></i> 查看', Url::to(['/store/order/view', 'id' => $model->orderStore->id]), ['class' => 'btn btn-info  btn-sm']);
                                    return $html;
                                },
                            ],
                        ]

                    ]);
                    ?>
                    <div class="text-right">
                        <?=Html::a('查看更多 <i class="fa fa-angle-double-right"></i>', Url::to(['/store/order/index']), ['class' => 'btn btn-primary  btn-sm']) ?>
                    </div>
                    <hr/>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <!-- Widget: user widget style 1 -->
            <div class="box box-widget widget-user">
                <!-- Add the bg color to the header using any of the bg-* classes -->
                <div class="widget-user-header bg-aqua-active">
                    <h3 class="widget-user-username"><?=$store->title ?></h3>
                </div>
                <div class="widget-user-image">
                    <img class="img-circle" src="<?=$store->logo ?>" alt="User Avatar">
                </div>
                <div class="box-footer">
                    <div class="row">
                        <div class="col-sm-4 border-right">
                            <div class="description-block">
                            </div>
                            <!-- /.description-block -->
                        </div>
                        <!-- /.col -->
                        <div class="col-sm-4 border-right">
                            <div class="description-block">
                            </div>
                            <!-- /.description-block -->
                        </div>
                        <!-- /.col -->
                        <div class="col-sm-4">
                            <div class="description-block">
                            </div>
                            <!-- /.description-block -->
                        </div>
                        <!-- /.col -->
                    </div>
                    <!-- /.row -->
                </div>

                <div class="box-footer no-padding">
                    <ul class="nav nav-stacked">
                        <li><a href="#"><b>联系人:</b> <?=$store->username ?></a></li>
                        <li><a href="#"><b>联系电话:</b> <?=$store->tel ?></a></li>
                        <li><a href="#"><b>所在地址:</b> <?=$store->location_p. ' '.$store->location_c . ' '.$store->location_a ?></a></li>
                        <li><a href="#"><b>详细地址:</b> <?=$store->address ?></a></li>
                    </ul>
                </div>
            </div>
            <!-- /.widget-user -->
        </div>
    </div>
</div>
